define(["app","js/patient/listView","js/init", 'js/utils','js/util/toast','js/util/socketUtil','js/risk/riskModel',"text!app/risk/main.html"], 
	function(app, listView,base,Utils,toast,initSocket,model,source) {
	
	//临时缓存数据
	var curConfig = {
		data		: null,
		deptData	: null,
		moduleCode	: "medical",
		method		: "getCurrentDept",
		bizcode		: null,
		bizname		: null
	} ;
	var $$ = Dom7;
	var bindings = [		
		//类型链接
		{
			element: '#patient-list-page .dept-itme-link',
			event: 'click',
			handler: clickType
		}
		,
		//全院情况
		{
			element: '#patient-list-page .button-all',
			event: 'click',
			handler: clickAll
		}
		,
		//科室分布
		{
			element: '#patient-list-page .button-dept',
			event: 'click',
			handler: clickDept
		}
		
		
	];

	/**
	 * 
	 * 点击全院情况
	 * 
	 */
	function clickAll(data){
		listView.renderPie({
			code	: curConfig.moduleCode,
			model	: data,
			bindings: bindings
		});
	}
	
	/**
	 * 
	 * 点击科室分布
	 * 
	 */
	function clickDept(data){
		listView.renderDept({
			code	: curConfig.moduleCode,
			model	: data,
			bindings: bindings
		});
	}
	
	/**
	 * 显示科室列表信息
	 */
	function renderDept(data){
		listView.renderDept({			
			model	: data,
			bindings: bindings
		});
	}
	
	function clickType(e){


		if(!app.mainView){
			app = app.getApp();
		}

		
		
		var deptid 
		if(e && e.currentTarget){
			deptid = $(e.currentTarget).attr('pid')
		}
		
		
		if(deptid){

			
			var _cv = app.f7.getCurrentView();			
			var _router
			if(_cv){
				_router = _cv.router			
			}else{
				_router = app.f7.views.risk.router			
			}
			
			_router.load({url:'app/patient/patientList.html',query:{deptid:deptid}});
			app.f7.showPreloader('loading...');
			//_router.reloadPage('app/risk/'+typeCode + '.html');
		}
	}
	
	
	/**
	 * 自定义查询部门合计信息
	 * @param query.code	业务模块代码
	 * @param query.method	查询方法定义
	 */
	function init(query){		
		
		
		
		if(!app.mainView){
			app = app.getApp();
		}
		
		//显示业务模块信息
		
		
		listView.renderPie({			
			model	: query,
			bindings: bindings
		});
		app.f7.hidePreloader();
			
		
	}

	return {
		init		: init,
		renderDept 	: renderDept
	};
});